package cn.edu.jiangnan.javaweblesson.controller;

import cn.edu.jiangnan.javaweblesson.entity.Obj;
import cn.edu.jiangnan.javaweblesson.common.Result;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.locks.ReadWriteLock;

@RestController
public class HelloController {

    // @RequestMapping(value="/",method = RequestMethod.GET)
    @GetMapping("/hello")
    public Result hello(String data) {
        return Result.success(data);
    }

    // @RequestMapping(value="/post",method = RequestMethod.POST)
    @PostMapping("/post")
    public Result post(@RequestBody Obj obj) {
        return Result.success(obj);
    }

    // @RequestMapping(value="/put",method = RequestMethod.PUT)
    @PutMapping("/put")
    public Result put(@RequestBody Obj obj) {
        return Result.success(obj);
    }

    // @RequestMapping(value="/delete",method = RequestMethod.DELETE)
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        return Result.success(id);
    }

    // 批量删除
    @DeleteMapping("/delete")
    public Result deleteBatch(@RequestBody List<Integer> ids) { return Result.success(ids); }
}